package cn.pcManage.shopManage.controller;

import cn.common.common.model.ServerResponse;
import cn.common.shop.model.BaseNoticeInfo;
import cn.pcManage.shopManage.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by Zhang on 2019/1/29.
 */
@RestController
@RequestMapping("/shopNotice")
public class NoticeController {
    @Autowired
    INoticeService iNoticeService;

    @PostMapping(value = "/addNotice")
    public ServerResponse<?> addNotice(@RequestBody BaseNoticeInfo noticeInfo){
        return iNoticeService.addNotice(noticeInfo);
    }

    @PostMapping(value = "/updateNotice")
    public ServerResponse<?> updateNotice(@RequestBody BaseNoticeInfo noticeInfo){
        return iNoticeService.updateNotice(noticeInfo);
    }

    @GetMapping(value = "/deleteNotice")
    public ServerResponse<?> deleteNotice(@RequestParam("id") Integer id){
        return iNoticeService.deleteNotice(id);
    }

    @GetMapping(value = "/changeOrder")
    public ServerResponse<?> changeOrder(@RequestParam("id") Integer id,
                                         @RequestParam("type") String type){
        return iNoticeService.changeOrder(id,type);
    }

    @PostMapping(value = "/getNoticeList")
    public ServerResponse<?> getNoticeList(@RequestBody BaseNoticeInfo noticeInfo){
        return iNoticeService.getNoticeList(noticeInfo);
    }

    @PostMapping(value = "/uploadImg")
    public ServerResponse<?> uploadImg(@RequestParam("file") MultipartFile multipartFile){
        return iNoticeService.uploadImg(multipartFile);
    }
}
